<?php
namespace App\Models\Admin;

class UserAccessModel extends BaseModel
{
    /**
     * 用户token
     */

    protected $table = 'users_access';
    protected $fillable = [
        'id','uid','token','created_at',
    ];

    /**
     * 通过Token，获取Uid
     */
    public static function getUidByToken($token)
    {
//        $dayStart = strtotime(date('Ymd',time()).'000000');
//        $dayEnd = strtotime(date('Ymd',time()).'235959');
        $model = UserAccessModel::where('token',$token)
//            ->where('created_at','>',$dayStart)
//            ->where('created_at','<',$dayEnd)
            ->orderBy('id','desc')
            ->first();
        return $model ? $model->uid : 0;
    }
}